package com.example.schoolmanage.Config;


import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * <p>
 * </p>
 *
 * @author yuxiaobin
 * @date 2018/1/23
 */
@Configuration
@EnableSwagger2
public class SwaggerConfig {
//获取swaggerword文档的方法
    //文档地址
    //url:http://localhost:8080/swagger-ui.html

    // json地址
    // http://localhost:8080//v2/api-docs

    // 通过json地址获取word文档方法
    // https://github.com/JMCuixy/swagger2word?login=from_csdn

    // 启动toword项目和本项目，将本项目的swagger的json地址粘贴到toward文档地址中提供的方法中，点击tryitout 生成
    // 注意同时启动本项目和toword项目要保证两者的端口号不一样

    @Bean
    public Docket docket() {

        return new Docket(DocumentationType.SWAGGER_2)
                .enable(true)
                //.apiInfo(apiInfo())
                .select()
                //.apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))
                .apis(RequestHandlerSelectors.basePackage("com.example.schoolmanage.controller"))
                .paths(PathSelectors.any())
                .build();
    }

//    private ApiInfo apiInfo() {
////        return new ApiInfo("Stanlogy Test",
////                "This is Sample",
////                "1.0",
////                "",
////                new Contact("anycase.cn", "", ""),
////                "anycase",
////                "http://www.anycase.cn"
////                , new ArrayList<>()
////        );
//    }
}
